/*HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
 H       PCB.h
 H       Application name: Program Control Block Header File
 H       Programmers names: Cristopher Claeys
 H       Date completed:
 H       Brief Description: This is the header file that defines an ADT for the PCB
 H
 HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH*/
#ifndef PCB_H_INCLUDED
#define PCB_H_INCLUDED

#include <pthread.h>
#include "cpu.h"
#include "process.h"

#define STATE_RUNNING 0
#define STATE_READY 1
#define STATE_INTERRUPTED 2
#define STATE_BLOCKED 3

typedef struct pcb_str {
    int pid;
    int next_step;		// this is the step count that the CPU had gotten to when this process was
						// prempted (like a PC register value)
	int state;			// e.g. 0=running, 1=ready, 2=interrupted, 3=blocked
	PQueue *waiting_on;		// which queue is it in if it is waiting on something (blocked)
	int owns;			// which semaphore does it own
	// anything else you need
	Process	proc;
	CPUPtr cpu;

} PCBStr;

typedef PCBStr * PCB;

extern PCB pcb_init(int, int, Process, CPUPtr);
extern void pcb_destroy(PCB); //Destroys the process inside the PCB as well as the PCB and resets
                        // the PCB to NULL.
extern void pcb_set_blocked_queue(PCB, PQueue *);
extern void *pcb_run(void *);

#endif // PCB_H_INCLUDED
